/**
 *  A Utility that watches the mouse and keybaords for event to do something like
 *  hint or run a attention grabber etc.
 * @author Troy Gardner
 */
class com.troyworks.framework.ui.UserIdleTracker extends MovieClip {
	
	public static var USE_IDLE_EVTD:String = "USER_IDLE";

	private var idleTime : Object;

	private var idleID : Object;
	public function UserIdleTracker(t:Number) {
		super();
		t = (t== null)?25:t;
		idleTime = t * 1000;
        idleID = -1;
        onEventHandler();
        onMouseDown =
        onMouseUp = 
        onMouseMove = 
        onKeyDown = 
        onKeyUp = 
        onEventHandler;
    	Mouse.addListener(this);
		Key.addListener(this);    
	}
	public function onTimeout() : Void {
        clearInterval(this.idleID);
        this.idleID = 0;

        trace("idle");
        // do whatever
	}

 	public function onEventHandler() : Void {
        clearInterval(this.idleID);
        this.idleID = setInterval(this, "timeout", this.idleTime);
	}	
}